<!--
 * @Descripttion: 
 * @Version: 
 * @Author: gaohj
 * @Date: 2023-01-10 16:16:26
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-01-10 16:41:32
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="content">千锋前端yyds,web3.0重磅发布,让学生了解未来互联网的样子</div>
    <button onclick="clearInterval(num)">暂停</button>
    <button onclick="num = setInterval(dengdeng,500)">开始</button>

    <script>
        function dengdeng() {
            var strs = document.getElementById('content').innerHTML;
            // '锋前端yyds,web3.0重磅发布,让学生了解未来互联网的样子千';
            // '前端yyds,web3.0重磅发布,让学生了解未来互联网的样子千锋';


            // 每次 截取第一个字符串 拼接到最后面 

            // 栈方法  push pop
            // 队列   unshift shift 
            // 数组 才有的方法  
            var arr = strs.split('');
            var first = arr.shift();
            arr.push(first);
            strs = arr.join('');

            document.getElementById('content').innerHTML = strs;
        }

        var num = setInterval(dengdeng, 500);
        // setInterval("dengdeng()", 1000);
        // setInterval(function(){
        //     dengdeng()
        // }, 1000);

        // clearTimeout(num);
        // clearInterval(num); //都可以取消定时器 
        // setTimeout 用 clearTimeout
        // setInterval 用 clearInterval
    </script>
</body>

</html>